import React, { Component } from 'react';
import styles from './TodoButton.module.css'
console.log(styles)

export default class TodoButton extends Component {
  onClickHandler = () => {
    // if (this.props.onClick) {
    //   this.props.onClick()
    // }
    this.props.onClick && this.props.onClick()
  }
  render() {
    console.log('获取props：', this.props);
    const { children, type } = this.props;

    const className = [styles.btn_default] // 默认 className

    if (type === 'primary') {
      className.push(styles.btn_primary)
    }

    return (
      <button className={className.join(' ')} onClick={this.onClickHandler}>
        {children ? children : '按钮'}
      </button>
    )
  }
}
